import { createWebHashHistory, createRouter } from 'vue-router';
import Login from  '../views/Login.vue';
import Home from  '../views/Home.vue';
import Users from  '../views/User/index.vue';
import Tasks from  '../views/Task/index.vue';

const routes = [
  {
    path: '/',
    component: Home,
    children: [
      { path: '/tasks', component: Tasks },
      { path: '/users', component: Users },
    ]
  },
  { path: '/login', component: Login },
  { path: '/:catchAll(.*)', redirect: '/' }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

// 路由日志功能观察导航过程
// router.afterEach((to, from) => {
//   console.log(`Navigated from ${from.path} to ${to.path}`)
// })

export default router;